package cn.fbs.enums;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.HashMap;

public class BaseEnumSerializer extends JsonSerializer<BaseEnum>{
    @Override
    public void serialize(BaseEnum baseEnum, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        HashMap<String, String> map = new HashMap<>();
        map.put("code", baseEnum.getCode());
        map.put("displayName",baseEnum.getDisplayName());
        jsonGenerator.writeObject(map);
    }
}
